#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
set<ll> st;
void init()
{
	ll sum=0;
	for(ll i=2;i<=100000;i++)
	{
		sum=1+i;
		for(ll j=i*i;j+sum<=(ll)1e18;j*=i)
		{
			sum=sum+j;
			if(sum>(ll)1e18) 
			{
				break;
			}
			st.insert(sum);
            if(j>1e18/i)
            {
            	break;
			}
			
//			cout<<sum<<'\n';
		}
	}
	
}
int main()
{
	IOS;
	init();
	int t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		if(st.count(n))
		{
			cout<<"YES"<<endl;
			continue;
		}
		ll l=2;
		ll r=1e9;
		while(l<r)
		{
			ll mid=l+r>>1;
			if(1LL+mid>=n-mid*mid) r=mid;
			else l=mid+1;
		}
		if(1LL+l+l*l==n) cout<<"YES"<<endl;
		else
		{
			l=2;
			r=1e6;
			while(l<r)
		    {
			    ll mid=l+r>>1;
			    if(1LL+mid>=n-mid*mid-mid*mid*mid) r=mid;
			    else l=mid+1;
		    }
		    if(1LL+l+l*l+l*l*l==n) cout<<"YES"<<endl;
		    else cout<<"NO"<<endl;
		}
	}

	return 0;
}

